Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Degree list #244

Merged
merged 11 commits into from
Feb 22, 2024
Merged

Degree list #244

merged 11 commits into from
Feb 22, 2024

Conversation

d-callan
Copy link
Contributor

resolves #239

@d-callan d-callan requested a review from asizemore February 16, 2024 03:39
@d-callan
Copy link
Contributor Author

i didnt do anything w weighted degree for now.

setMethod("Node", "numeric", function(id, x = numeric(), y = numeric(), color = NULL, weight = NULL) {
new("Node", id = NodeId(as.character(id)), x = x, y = y, color = color, weight = weight)
setMethod("Node", "numeric", function(id, x = numeric(), y = numeric(), color = NULL, weight = NULL, degree = NULL) {
degree <- ifelse(is.null(degree), 0, degree)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

degree should be null until it's set to something. degree = 0 says we actually know something about this node in the network

)
nodeC <- Node(
id = NodeId('C')
id = NodeId('C'),
degree = 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think the degree should allowed to be set when creating a node. The degree is not a thing outside of the network context. First, I could have nodeA in network1 and network2. There's no reason nodeA should have the same degree in both.
Second, i could set it wrong. Why would i know that nodeA will have two links when i haven't made the edge list yet? These degrees aren't connected to the edge list at all

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if i just dont export it from the package, and it can only ever be used internally? i dont see why, if you have an edgeList in hand, you shouldnt be able to create the node already knowing the degree. but i agree random people shouldnt make random nodes w random values for degree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think id even be happy if the only thing we actually did export were the edgeList based constructors, particularly for now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense to me!

@asizemore
Copy link
Member

Idk where my review button went but anyways

  • the degree part above is most important. Having the degree be a node prop is fine, but it should only ever be set within the context of a Network because it has the EdgeList. A lone node doesn't have a degree or any concept of what that means becuase it's just a node. Something like net <- setNodeDegrees(net).

@d-callan d-callan merged commit c4b40c4 into main Feb 22, 2024
5 checks passed
@d-callan d-callan deleted the degree-list branch February 22, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Network: add support for finding degrees for nodes
2 participants